package com.blackshadowgame.rps;

public class InputCode {
    public static final int NONE_0 = 0;
    public static final int ROCK_1 = 1;
    public static final int SCISSORS_2 = 2;
    public static final int PAPER_3 = 3;

    public static String getInputCodeName(int code){
        String s = "未知";
        switch (code){
            case ROCK_1:
                s = "石头";
                break;
            case PAPER_3:
                s = "布";
                break;
            case SCISSORS_2:
                s = "剪子";
                break;
        }

        return s;
    }

    public static int calculateWinner(int a, int b){
        if(a == b){
            return 0;
        }

        int winner = 1;
        switch (a){
            case ROCK_1:
                if(b == PAPER_3){
                    winner = -1;
                }else{
                    winner = 1;
                }
                break;
            case PAPER_3:
                if(b == SCISSORS_2){
                    winner = -1;
                }else{
                    winner = 1;
                }
                break;
            case SCISSORS_2:
                if(b == ROCK_1){
                    winner = -1;
                }else{
                    winner = 1;
                }
                break;
        }

        return winner;
    }
}
